package h0708;


import java.util.*;
import java.util.function.Function;

public class TestCaseExecutePlan2 {
    static class TestCase{
        int id; //记录原始下标顺序
        int priority;

        public TestCase(int id, int priority) {
            this.id = id;
            this.priority = priority;
        }
    }

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        //
        int featureNum = sc.nextInt();
        int caseNum=sc.nextInt();

        //优先级大的用例先执行，如果存在优先级相同的用例，用例 ID 小的先执行。
        int[] features=new int[featureNum];
        for (int i = 0; i < featureNum; i++) {
            features[i]= sc.nextInt();
        }
        sc.nextLine();
        List<TestCase> cases=new ArrayList<>();
        for (int i = 0; i < caseNum; i++) {
            String s = sc.nextLine();
            int[] temp = Arrays.stream(s.split(" ")).mapToInt(Integer::parseInt).toArray();
            int sum = Arrays.stream(temp).sum();
            cases.add(new TestCase(i+1,sum));
        }
        cases.stream().sorted(new Comparator<TestCase>() {
            @Override
            public int compare(TestCase o1, TestCase o2) {
                //先根据优先级比较，从大到小。
                if (o1.priority!=o2.priority){
                    return o2.priority-o1.priority;
                }else {
                    //优先级相同，按照id
                    return o1.id- o2.id;
                }
            }
        }).map(new Function<TestCase, Object>() {

            @Override
            public Object apply(TestCase testCase) {
                return testCase.id;
            }
        }).forEach(System.out::println);
    }
}
